import type {RouteLocationNormalized} from 'vue-router';
import type {TagProps} from '@/store/modules/tab-bar/types';

/**
 * 重获向模版
 */
export const REDIRECT_ROUTE_NAME = 'redirect';

/**
 * 默认模板
 */
export const DEFAULT_ROUTE_NAME = 'workplace';

/**
 * 默认模板路径
 */
export const DEFAULT_ROUTE_FULL_PATH = '/dashboard/workplace';

/**
 * 404 模版
 */
export const NOT_FOUND_ROUTER_NAME = 'notFound';
export const FORBIDDEN_ROUTER_NAME = 'forbidden';

/**
 * 登录 模版
 */
export const LOGIN_ROUTE_NAME = 'login';

export const WHITE_LIST = [
    {name: LOGIN_ROUTE_NAME, children: []},
    {name: REDIRECT_ROUTE_NAME, children: []},
];

export const NOT_FOUND = {
    name: 'notFound',
};

/**
 * 状态路由
 */
export const STATUS_ROUTER_LIST = [
    {name: NOT_FOUND_ROUTER_NAME, children: []},
    {name: FORBIDDEN_ROUTER_NAME, children: []},
];

/**
 * 默认 tab 页面
 */
export const DEFAULT_ROUTE = {
    title: '工作台',
    name: DEFAULT_ROUTE_NAME,
    fullPath: DEFAULT_ROUTE_FULL_PATH,
};

/**
 * router 转 tag
 */
export const routerToTag = (route: RouteLocationNormalized): TagProps => {
    const {name, meta, path, fullPath, query} = route;
    return {
        title: meta.locale || '',
        name: String(name),
        // @ts-ignore
        path,
        fullPath,
        query,
        ignoreCache: meta.ignoreCache,
    };
};
